# 定义变量
$SERVER_NAME = "user"
$SERVER_TYPE = "rpc"
$VERSION = "latest"
$DOCKER_REPO_TEST = "registry.cn-hangzhou.aliyuncs.com/myeasy-chat/${SERVER_NAME}-${SERVER_TYPE}-dev"
$APP_NAME_TEST = "easy-chat-${SERVER_NAME}-${SERVER_TYPE}-test"
$DOCKER_FILE_TEST = "./deploy/dockerfile/Dockerfile-${SERVER_NAME}-${SERVER_TYPE}-dev"

# 编译 Go 程序
$env:GOOS = "linux"
$env:GOARCH = "amd64"
$env:CGO_ENABLED = "0"
go build -o "bin/${SERVER_NAME}-${SERVER_TYPE}" "./apps/${SERVER_NAME}/${SERVER_TYPE}/${SERVER_NAME}.go"

# 构建 Docker 镜像
docker build . -f $DOCKER_FILE_TEST --no-cache -t $APP_NAME_TEST

# 打标签
docker tag ${APP_NAME_TEST} ${DOCKER_REPO_TEST}:${VERSION}

# 推送镜像
docker push "${DOCKER_REPO_TEST}:${VERSION}"